package com.briup.config;

import com.briup.web.filter.UserFilter;
import com.briup.web.listener.ApplicationListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebAppConfigure {
    @Autowired
    private ApplicationListener applicationListener;
    @Autowired
    private UserFilter userFilter;
    @Bean
    public ServletListenerRegistrationBean listenerRegistrationBean(){
        ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
        servletListenerRegistrationBean.setListener(applicationListener);
        return servletListenerRegistrationBean;
    }
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(userFilter);
        filterRegistrationBean.addUrlPatterns("/toShopCar","/toOrder",
                "/toCollect","/collect","/addCollect","/delCollect",
                "/findCollect","/paySuccess","/createOrder","/confirmOrder",
                "/advanceOrder","/toUserInfo","/userInfo","/addShopCar","/updateShopCar","/delShopCar");
        return filterRegistrationBean;
    }
}
